<?php
/**
 *
 * @file sqlite3.php
 *
 *
 * New BSD License
 * \n
 * Copyright (c) 2010 Rpd-Team
 *
 * @namespace  rpd
 * @since      0.0.1
 */

// namespace ;

/**
 *
 * Adapter for SQLite3.
 *
 * @copydoc Db
 *
 *
 * See also:
 *  @see
 *
 *
 * New BSD License
 * \n
 * Copyright (c) 2010 Rpd-Team
 *
 * @namespace  rpd
 * @since      0.1.0
 */
class Db_Adapter_sqlite3 extends Db_Adapter implements Db_Adapter_Interface
{
	function database($name)
	{
		$this->_link->open($name);
	}

	function encoding($charset)
	{
		return false;
	}

	function insert_id()
	{
		return $this->_link->lastInsertRowID();
	}

	function query($statement, $values = NULL)
	{
		$statement = $this->_escape($statement,
		                            $values,
		                            array($this->_link, "escapeString"));

		$result = $this->_link->query($statement);

		if ($result === true)
		{
			return true;
		}

		return new Db_Statement_sqlite3($result, $statement);
	}

	function __construct($settings)
	{
		$this->_link = new SQLite3($settings["database"]);
	}
}

?>